home *** CD-ROM | disk | FTP | other *** search
- /*
- (C) 1995-96 AROS - The Amiga Replacement OS
- $Id: settaskpri.c,v 1.4 1996/08/13 13:56:08 digulla Exp $
- $Log: settaskpri.c,v $
- Revision 1.4 1996/08/13 13:56:08 digulla
- Replaced __AROS_LA by __AROS_LHA
- Replaced some __AROS_LH*I by __AROS_LH*
- Sorted and added includes
-
- Revision 1.3 1996/08/01 17:41:20 digulla
- Added standard header for all files
-
- Desc:
- Lang: english
- */
- #include <exec/execbase.h>
- #include <aros/libcall.h>
-
- /*****************************************************************************
-
- NAME */
- #include <clib/exec_protos.h>
-
- __AROS_LH2(BYTE, SetTaskPri,
-
- /* SYNOPSIS */
- __AROS_LHA(struct Task *, task, A1),
- __AROS_LHA(LONG, priority, D0),
-
- /* LOCATION */
- struct ExecBase *, SysBase, 50, Exec)
-
- /* FUNCTION
- Change the priority of a given task. As a general rule the higher
- the priority the more CPU time a task gets. Useful values are within
- -127 to 5.
-
- INPUTS
- task - Pointer to task structure.
- priority - New priority of the task.
-
- RESULT
- Old task priority.
-
- NOTES
-
- EXAMPLE
-
- BUGS
-
- SEE ALSO
-
- INTERNALS
-
- HISTORY
-
- ******************************************************************************/
- {
- __AROS_FUNC_INIT
-
- BYTE old;
-
- /* Always Disable() when doing something with task lists. */
- Disable();
-
- /* Get returncode */
- old=task->tc_Node.ln_Pri;
-
- /* Set new value. */
- task->tc_Node.ln_Pri=priority;
-
- /* Check if the task is willing to run. */
- if(task->tc_State!=TS_WAIT)
- {
- /* If it is in the ready list remove and reinsert it. */
- if(task->tc_State==TS_READY)
- {
- Remove(&task->tc_Node);
- Enqueue(&SysBase->TaskReady,&task->tc_Node);
- }
-
- /*
- I could check the task priorities here to determine if
- the following is really necessary, but OTOH priority
- changes are rare and the hassle isn't really worth it.
- */
-
- /* Are taskswitches allowed? */
- if(SysBase->TDNestCnt>=0||SysBase->IDNestCnt>0)
- /* No. Store it for later. */
- SysBase->AttnResched|=0x80;
- else
- {
- /* Switches are allowed. Move the current task away. */
- SysBase->ThisTask->tc_State=TS_READY;
- Enqueue(&SysBase->TaskReady,&SysBase->ThisTask->tc_Node);
-
- /* And force a rescedule. */
- Switch();
- }
- }
-
- /* All done. */
- Enable();
- return old;
- __AROS_FUNC_EXIT
- } /* SetTaskPri */
-